writing pseudo code for handling collisions