refactor the code in order to use the new drag events