Refactor using request library