tried to refactor so that less garbage is generated. not quite successful