adding solution to #2
sol 2