creating function random
correcting function