restructure module method and organize some stuff