fixed name and added protection against NPE, part of #1465