Its better to use the publish callback instead of a timer to avoid a race condition