Fix potential nullPointerException