Implemented nested loop check. Works like a charm :)