externalise some utility code functions
externalise some utility code functions