Add a function to calculate collisions