moving code from main-random init