Fixed a problem with var not being set properly