Refactoring map state into a controller