Refactored several solutions to remove deep nesting