Refactor to fix frozen hash issue