converted utility functions from expressions to declarations so as to be able to move them to the end of the file and out of the way.