adding register management
small change to support register number