changed getdata to use length instead of index to