Created proper error handling.