Added checkForAlert function