updated color function to use values from key array