Refactor led switching to functions.