move implementation out from api