completed AMD refactoring, polishing the impl