Rewrite using array search, 50% faster