more code refactoring