adding doc and refactor some class