Fixed the need of a global variable