commented code and added a curl request function