refactored to use pems, added retry logic to poll while system is reconfiguring