modify the drag judgement & make variable declare first