add more functions, and some refactoring