probably correct reg logic