custom function to calculate difference in two arrays