review the code and fix bugs and error, make sure the functions are working