added admin controller and refactored code