basic functions for ad ranking