simplify and add more tests
add documentation