Reduce duplication beetwen api v2 and api v3