Added sampling function