simplify by using generators
add docs on usage