refactor color logic