add heartbeating function