used some tricks to make the collision time become 0 if it is very small