while instead of if for offset management functions