Moved if/else alerts into while loop