Refactored controller
Added error handler and error page