complete heartbeating function