refactored soln