another solution (solver2)