complete the code and docs