Auto complete p function