Debug statements for onEnter function
Refactored sync() to use callbacks