separate main heartbeat logic