fix NullPointerExceptions