fixed func and rand