starts work on controller and adds error handling