Avoid usage of sample which raises error  in ruby 1.8.7