fix polling issue by making heartbeat it's own function