added better random function