extracted method retrieveStats and fixed callback error