adding controller error handling