Refactor to callbacks