added main() so it can be unit tested