factor out color handling