First implementation of collision algorithm