Cleaned up code for dragging and dropping