Fixing bug in the dragging motion