better error checking for back reference