created a heartbeat function