Restructured LED control code