moved error tracking enable to a function