Fixed bugs added exception catching