Exchange transaction

Hello. I seem to be making a mistake limiting buy order price with this script. Buy and sell orders are getting confirmed with the defined sellprice. How can we check if the ExchangeTransaction is a buy or sell order? Looks like e.sellOrder.price or e.buyOrder.price gives the same value.

let sellprice = 10
let buyprice = 8
match tx {
case e:ExchangeTransaction =>
if !isDefined(e.sellOrder.assetPair.priceAsset)
then
let sellpricecheck = e.sellOrder.price = sellprice
sellpricecheck && selltimeintervalcheck
else
let isitbuyorder = false
if !isDefined(e.buyOrder.assetPair.priceAsset)
then
let buypricecheck = e.buyOrder.price = buyprice
buypricecheck && buytimeintervalcheck
else
let isitsellorder = false
if isitsellorder == false && isitbuyorder == false
then false
else true
case _ => false
}

I have simplified the script like this. But both buy and sell orders are accepted if the price is 10. I cannot seem to limit buy order price with 8. What am I doing wrong?

{-# STDLIB_VERSION 3 #-}
{-# CONTENT_TYPE EXPRESSION #-}
{-# SCRIPT_TYPE ASSET #-}
let sellprice = 10
let buyprice = 8
match tx {
case e:ExchangeTransaction =>
let isitsellorder = e.sellOrder.orderType
if isitsellorder == Sell
then
let sellpricecheck = e.sellOrder.price == sellprice
sellpricecheck
else
if isitsellorder == Buy
then
let buypricecheck = e.buyOrder.price == buyprice
buypricecheck
else
false
case _ => false
}