sql modules refactoring