refactor rest examples