refactoring controller, updating tests