fix array flip condition