Fixed bug when array is length one or zero.