Added heartbeat code