Fix random range bug