whereSafe function