The problem is coming because if you only have a last name, all you have is arr(0). You can't refer to arr(1) or above in that case.