Modify overhang detection algorithm