Getting stuck in a loop even when the conditions for the statement changes

You don't need the second if(). When the first one is not true, then just do the lightBad();