refactor code to use module