cleaned up handleMouseClick