add two functions to reg.cpp