improve error handling message, refine exception catching