fix bug in solution 2