Fixed a bug with ex3.6 solution