added variable cache for better error checking