fix bugs and comment the classes and functions