sql file refactored