Better parameter handling in random function