updated query from flip