Avoiding spaghetti code