attempt to refactor api
done refactoring and documenting