Refactor to modules