moving rand to swift