"Wait" action within a function is very weird.
1 After the "Wait" action is executed, Funttion.Param(x) are reset to zero
2 Actions inside the Function folowing the "Wait" action are executed more than once, a random number of times.
That can make a programmer crazy.