refactor solution to #125