Change flash detection code