added a null check to player collision detection