Making sure that null elements in the list don't cause a 500 error (NPE)