added better error checking on variable names