merged potential analysis functions from ews and Rshiny to avoid the need to maintain multiple parallel versions