fix bugs and new functionalities