I would like you to move this into a utility class of some sort or prototype this into an existing utility class. I would like as few global variables as possible