refactoring curl wrapper