refactoring, some changes