Added an extra check that there is a variable