create drag function but it has some errors