added flash detection