add variables and error function