Wrapped random in a function