fixed gap direction, but still getting floating point rounding issue