extract variables function ready and implementing the first pass