added collisionHappened method and refactoring afterwards