another solution, similar as solution1