code refactoring, removing some redundant codes
code refactoring, integrating outer functions to ms object