implemented local-var optimization