Null Pointer exception on nonexistent indices