working code programming assignment 1 part 2