db changed and code refactoring.