factor out colourmap; fix bug on repeated run