use db context correctly
massive refactoring, will break