adding globals so loop functions work