small refactoring - using maps instead of arrays now.