bugfix: change two variables from global to local scope