finall fixed corner cases, now gets 97%