Finished and tested 'GeneR' function