I think all this chunk of code regarding the flashing or not could be better