fixed infinite loop in Gift Wrapping implementation