refactorized RNG version and checked it's working as expected