Fixed error with not using correct variable