add the within scalar function