finished codes and begin to write docs