Tiny refactor to a function in controllers/utils