added main function with basic exception catching