Added error handling when 500 error is returned.