iteration now handles a null pointer exception