Refactor to use callbacks
Refactor to use callbacks