[ApT] use more general functions to simlify code