Fixed global state issue