first pass at adding in variable checking. not sure if this will work