Changed stop criteria to use .equals() instead of ==