stuck trying to get heartbeat function to work