refactor response creation move code from controller to model