random mode, fix a bug