refactoring the controllers -  magic