Fixed use of global variable