refactor some curl calls