moved rand to be a function level variable comparred to a class level variable