appmanage: code refine; make function easy to use;