Safer version of xap()