Updated to work with callbacks