modified rand method