Fixed bug that caused LED not to being turn off in certain cases