Added function for expanding expressions containing local variables