Add more flexible code to Randomclass