Adding success flag check