fix #215 Variable scope problem