fix many bugs and add many try/except