In original code always will be 100% prob. I think that in catch it should execute a continue, so heart_beat_index doesn't increment.

Do you think so too?