Refactor to a separate module