Added variable checking