Add exit on error
Fix a bug