Updated heatbath with array implementation