fixed generateGaps