Refactor to make callbacks idiomatic