Fix NPE --Thanks to Dokdo, lion0738