- Refactored heatMap function