Refactor WRM controller