change error retval -1 to 0