change names for some variables and functions. add error message