Added hash recursive helper function