Refactored with update_all_leds function.