code re factor for the callback.