refactoring: moving check if colors is defined into setPixel function