Better control flow and removing impossible len(arr) == 0 case