@Override
    public void run() {
        while (read && lastMessage == null) {
            lastMessage = messageReader.getLastMessage();
        }

        while (read) {
            Message message = messageReader.getLastMessage();

            if (message != null) {
                if (message.getTime() == lastMessage.getTime()
                    && System.currentTimeMillis() - lastMessage.getTime() > 10000) {
                    lastMessageTimer = false;
                } else if (message.getTime() == lastMessage.getTime()
                    && System.currentTimeMillis() - lastMessage.getTime() > 3000) {
                    lastMessageTimer = false;
                } else {
                    lastMessage = message;
                    heartRate = lastMessage.getHr();
                    lastMessageTimer = true;
                }
                try {
                    Thread.sleep(500);
                } catch (InterruptedException ex) {
                    Logger.getLogger(Main.class.getName()).
                            log(Level.SEVERE, null, ex);
                }
            }
        }
    }