return -1 on error
return -1 on error