refactoring of controller and model methods