updated collision algorithm