Refactored the random method in floating classes.