refactoring a bit to fix circular import issue