Add some error checking to response, replace magic with regex