Rewrite alter without using continuations.