added bounds checking for mouse clicks