improve variable handling
Merge pull request #95 from williampma/variable_improvement

improve variable handling