Fix NullPointer bug