added type checking for  variable types