added error message when attempting to replace variables in undef