Added extract variable function