removing the undefined variable and replacing w original string