checking requests status code made more pythonic