fix variable name clash
break up long function to specialise it later
don't pass unused arguments