add erro handler and code to exit if any problem