bug fixed rand