refactor

- extract current-word selection into function (TODO move into util?)
- make variable names more descriptive