timer and collision detection