refactored controler