changed condExprHelper function to a pattern matching on the list