controllers refactoring, bug fix