fixed a NPE bug