added random selection; first working version