rewrite edit() securing the critical section
rewrite edit() to be more readable
rewrite mv() securing the critical section