working code
working code branched off for testing