added rnd and fixed some things