refacto api handler & AMR