implementation of callback, but not certain it is correct, debugging with callbacks