Changed x from being a local var to a global