Fixed #3 solution