implementation of module similar to Enumerable