draggable: refactor code