Refactored DataService; added error log and optimized code.