bug fix

handle cases where rewritten doesn't happen due to
ill-formed code