remove some slow logic

Lets loop through the array once instead of three times (build boolean
array, convert to list, then scan for first false)