Improved while loop SA, added better ST checking for conditions