postgres module refactoring