refactor to reuse rest calls