working on plugin appleiap, compile pass but need refactoring