beginning of drag code