refactor some parts of the code and review API