welp, totally broken. need to refactor psi api to not use globals