Solving 0 length array issue