refactored somewhat into classes, still a long way to go to object oriented programming but its a start