fixed overlap function, adjusted for comparing moving lines