Problem while sampling randomly