refactored to make sure there are no errors with chaining http requests