now working except for the final print

Some sloppy coding in places that needs to be tightened, but it works