update color palette, fix reduce function