changed code to use a persistent map again