improved doc and some funcs