fix bug

-ArrayIndexOutOfException and NullPointerException