sample factor changed to more sutable and added check for data