add safety checking for dragElement