more refactoring, minor code refactor