Adding the exit statement on error