slowly converting this to work with the APM