Re-Factoring DB script