cleaning collision algorithm