Cleaned up code, need to test to make sure all works and implement part 3