refactoring keyvalue register