modified inline to calculate difference