fixed bug for NullPointerException