rewrite some date structure and implements getReg()