added variable checking