Refactoring create_app method