refactoring, and add isLedOutOfBounds.