move more logic out of controllers