fix potential NullPointerExceptions