return 0 on success, positive number on fail