Rewriting controllers