Made function public, because callback function can't access private methods