revised refactored solutions