minor
breaking out into functions
nearly finished functions which extract generic parameters from script