tried to tidy up the configuration code to make it more re-usable