Weighted random algorith developed