reorganized code into module