refactor and oncompletion listener (minor)