filter |replace properly handles undefined