refactor color parsing method to avoid bug