added the rest of the callback logic