Refactoring to useing curl wrapper