modified the reg functions