finished part 3, various bug correction