factor out implementations