Fixed variable scope error that prevented correct dragging handling