move methods from controller to model