Second part of week 2 solution