changes to maps and nested loop