Refactered code for LED Project