Refactoring to improve metrics