fixed heartbeat code