using gen function for dimming task