undefined replacement issue