Compile ride files. Parsed.Failure

I wrote the ride code below. But the compilation report Parsed.Failure(Position 4:1, found “func p22 (”).
Could anybody help me?

{-# STDLIB_VERSION 5 #-}
{-# SCRIPT_TYPE ACCOUNT #-}
{-# CONTENT_TYPE DAPP #-}
func p22 (v) = match v {
case x: (Int, Int, Int, Int, Int,Boolean) =>
x._2
case t =>
throw(“p22”)
}

let a = base58’6XtHjpXbs9RRJP2Sr9GUyVqzACcby9TkThHXnjVC5CDJ’

let d = addressFromStringValue(“3PGCkrHBxFMi7tz1xqnxgBpeNvn5E4M4g8S”)

let m = addressFromStringValue(“3PAZv9tgK1PX7dKR7b4kchq5qdpUS3G5sYT”)

func n () = {
let b = assetBalance(d, a)
if ((10 > b))
then 0
else {
let z = p22(invoke(d, “userBalance”, [toString(this)], nil))
let i = invoke(m, “withdraw”, [toBase58String(a), if ((b > z))
then -1
else b], nil)
if ((i == i))
then 1
else throw(“Strict value is not equal to itself.”)
}
}

@Callable(i)
func f () = if ((i.caller != this))
then throw(“admin”)
else if ((n() == -1))
then throw(“too low reserve”)
else nil

@Callable(i)
func g () = if ((i.caller != this))
then throw(“admin”)
else {
let b = assetBalance(d, a)
if ((b == b))
then if ((100000000 > b))
then throw(“too low reserve”)
else {
let z = p22(invoke(d, “userBalance”, [toString(this)], nil))
if ((z == z))
then {
let x = invoke(addressFromStringValue(“3PAZv9tgK1PX7dKR7b4kchq5qdpUS3G5sYT”), “withdraw”, [toBase58String(a), if ((b > z))
then -1
else b], nil)
if ((x == x))
then nil
else throw(“Strict value is not equal to itself.”)
}
else throw(“Strict value is not equal to itself.”)
}
else throw(“Strict value is not equal to itself.”)
}

Hey, we are more active in Telegram. Welcome in dev chat - Telegram: Contact @waves_ride_dapps_dev