define main, and add a try block