added the handling of collisions