fix exception errors when refactoring the previous commit