working on random algroithm