Corrected a possibly NullPointerException