Moved httprequest logic to a State monad