Define myerror before using it

The myerror function is already called before it is defined.
Move the function above the first call.