fixed bug in reg.