Bug in gap checking