added some state logic for LED