copied in barcode gap functions