Added checking not null, changed iterator class