fixed the NullPointerException bug