added conditional statements to control LEDs