used native for loop as ng forEach doesn't have break support.