added APS function, untested