modules for heatmap: some logic reorganization