End of part 2, needs debugging