more splitting out and refactoring - looks like a lot more code :-( but will be easier to manage for testing etc