controller rewritten