errors fixed with test codes