Fix #625

Fix #625 issue caused by unitialised variable.

Looks like someone placed the assignment of the variable inside of the if statement by mistake. This requires testing as its super annoying to work out when its working correctly.