differentiate.* added check on sample time, need some more modifications