Duplicate code for color handling replaced by function call.