corrects random calculation