Definitely could use some optimization in not creating so many new maps, but runtime is acceptable for now.