Updated register function (may not work/compile)