Code

Updated error handling