fix NullPointer

@crankycoder is this all it needs to fix #985 ?