Implemented the functionality of the callback in the library interface. Also added tests for it which pass.