remodeled generate_heatmap function