extract some api logic to method