Refactored existing code and added classes to enable database connectivity