Updated controller
Implemented common functionality