refactoring, moving code from controller to model, pending spec