Almost working collision algorithm