split code up and start to add persistence functionality