added random sampling