Collision detection in Erlang