cleaned up the get_deltas routine