completely restrucure so that it uses AMD pattern