random with missing dataset and a code not so dirty