Refactoring SQL class