return 0 if it succeed and -1 if it fails.