more changes to refactor, work in progress. lots more to come