refactor color conversion