fixed building sql tags condition