Added code to handle error. Ready to ship