Better exception handling in program