led function rewritten