Added NullPointer catch