# How can I check if $n >m$ in $a^n b a^m$?

How can I design a Turing machine that takes string $$a^n b a^m$$ and check if $$n>m$$ then convert the string to $$a^{n-m}$$, otherwise reject it?

Start with placing tape over $$b$$, then go to the rightmost $$a$$, put blank, go back to $$b$$ and delete the rightmost $$a$$.
Every time you scratch out $$a$$s on both sides, $$n - m$$ does not change until one side is blank.
Check if the left side is not empty, delete $$b$$ (and if it is required, go back to the beginning of the tape) and accept, otherwise reject.