rename some variables
move some api logic to class