better exception handling and priting