Fixed code errors appeared after refactoring