modified and add some new functionalities