Correction for a potential NullPointerException