Fixed a NPE bug