onMouseDrag function is now working almost properly