refactored rgb generating method