refactored controller a tad