I think this version works fine now

The function interface is clean
TODO:
1. Implement some algorithm such as reduce/map/filter based on each
2. Can the code be cleaner? (Compile faster)