changed method of generating random registration code