Refactor to use a hash