Updated example code and fixed callback bug