if else spacing array.length optimization