refactor "return result" to take cb, count and offset in and return a function def