some more code refactoring