refactoring, tidied up, removed superfluous stuff