added check to discard heartbeats from the past