Moved request creation to function