refactoring, fully working, need to migrate database to datahub