Refactor to use modules