TODO
[ ] doc
[ ] test cases
[ ] further optimization