moved functions from Application to SAPI