add some docs and fix a bug