before and after register functions