Updated code to get variables of each equation