add some checks to prevent and endless loop in collision