updated code with draft of first part of part 6!