Bug if length of array is 0