slight optimization, lose distance square root