refactoring
working?...now to add GUI?