refactor code to use better modules