Bug fix for incorrect var check