return -1if length is unknown