schema update & code refactoring