factored out callback.