added code to handle mouse clicks, needs refinement