homework 6 is working. major refactoring needed.