Simplify 'edit' function

Here's my last suggestion without radically restructuring things. Hope this helps :)