refactoring Controller in smaller methods