refactor rand transform/scale logic