improve code quality and add module pattern