Fixed global variable error