Refactor to use typedef for easier testing of different types