fixed nullpointer and arrayindex
First commit