error handling added to controller