pruning and refactoring