Cleanup sql script
Restructured & Refactored