improve pabs function