moved the heartbeat code