drag bug fix and refactoring