implementing Random Selection Algorithm