separate request function from click handler