apply function with all combination