updated to using main() scheme