added missing exit(0) command on error