template refactoring
state changes to go from id to key