return -1 if data is NULL