better main function for testing