refactored code from test program into the package