Added a heartbeat function