rename url to URL
extract error handler to separate method to avoid duplication