refactor utility code out into separate library