diff --git a/application.hpp b/application.hpp
index 5ba4b7d02ccf84f794bb60ff0753fed908297022..38c7bf67a02f12fd7fae643d3951bcfda56e1d7e 100644
--- a/application.hpp
+++ b/application.hpp
@@ -54,7 +54,6 @@ class Application
     protected:
         std::vector<Widget*> widgets;
         GameMaster *_game;
-        int _focus;
 };
 
 #endif // APPLICATION_HPP
diff --git a/button.cpp b/button.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..60adeeba4385a8c81e372b3cfa6cb3c7a4e41922
--- /dev/null
+++ b/button.cpp
@@ -0,0 +1,42 @@
+#include "button.hpp"
+
+using namespace genv;
+
+Button::Button(Application* parent, int x, int y, int szel, int mag,
+               std::string cimke, std::function<void()> f):
+    Widget(parent, x, y, szel, mag), _cimke(cimke), _f(f) {}
+
+
+void Button::rajzol() const
+{
+    // hatter
+    gout << color(dark_purple);
+    gout << move_to(_x,_y) << box(_szel,_mag);
+
+    // keret
+    gout << color(light_purple);
+    gout << move_to(_x,_y) << line(_szel,0) << line(0,_mag) << line(-_szel,0) << line(0,-_mag);
+
+    // szoveg
+    gout << font("LiberationSans-Regular.ttf",20);
+
+    gout << move_to(_x+ (_szel-gout.twidth(_cimke))/2,
+            _y+(_mag-gout.cascent()-gout.cdescent())/2)
+
+         << text(_cimke);
+}
+
+void Button::kezel(event ev)
+{
+    if (ev.type == ev_mouse && ev.button==btn_left
+        && belul(ev.pos_x,ev.pos_y))
+    {
+        action();
+    }
+}
+
+void Button::action()
+{
+    _f();
+}
+
diff --git a/button.hpp b/button.hpp
new file mode 100644
index 0000000000000000000000000000000000000000..7b0034408eb4d3c9e5b7f2aa9c1bbe0084c77203
--- /dev/null
+++ b/button.hpp
@@ -0,0 +1,25 @@
+#ifndef BUTTON_HPP
+#define BUTTON_HPP
+
+#include "widget.hpp"
+#include <functional>
+
+
+class Button : public Widget
+{
+    public:
+        Button(Application* parent, int x, int y, int szel, int mag,
+               std::string cimke, std::function<void()>);
+
+        virtual void rajzol() const override;
+        virtual void kezel(genv::event ev) override;
+
+        void action();
+
+    protected:
+        std::string _cimke;
+        std::function<void()> _f;
+
+};
+
+#endif // BUTTON_HPP
diff --git a/field.cpp b/field.cpp
index cb6942d5c6e26180f2d48edbf80044ae28caddf6..83c715eb102fc5f32d2ce2fe1d94d701422d60d8 100644
--- a/field.cpp
+++ b/field.cpp
@@ -80,8 +80,6 @@ void Field::rajzol() const
                _y+(_mag-gout.cascent()-gout.cdescent())/2)
 
          << text(std::to_string(_ertek));
-
-         //gout << text(" ") << text(std::to_string(_aura));
     }
 }
 
diff --git a/gamemaster.cpp b/gamemaster.cpp
index 2a2bd4db6568a5e2da9cc3cfee07647d11b131dd..f52cc4d57f586d38c68ecb978d1e1beefee4f0dd 100644
--- a/gamemaster.cpp
+++ b/gamemaster.cpp
@@ -58,19 +58,27 @@ set<int> GameMaster::aura(int jelenlegi_int)
     return s;
 }
 
-vector<int> GameMaster::szabalytalan(int jelenlegi_ertek, vector<vector<int>> aura_ertekek)
+set<int> GameMaster::szabalytalanok()
 {
-    vector<int> v;
+    set<int> s;
 
-    for (int i=0; i<aura_ertekek.size(); i++)
+    for (int i=0; i<_save.size(); i++)
     {
-        if (aura_ertekek[i][1] == jelenlegi_ertek)
+        std::set<int> aura_halmaz = aura(i);
+        for (int j=0; j<_save.size(); j++)
         {
-            v.push_back(aura_ertekek[i][0]);
+            if (aura_halmaz.find(j) != aura_halmaz.end())
+            {
+                if (_save[i] == _save[j] && _save[i]!=0)
+                {
+                    s.insert(j);
+                    //cout << i << " " << j << " " <<_save[i] << " " << _save[j] << endl;
+                }
+            }
         }
     }
 
-    return v;
+    return s;
 }
 
 int GameMaster::negyzet_szama(Index jelenlegi)
@@ -104,6 +112,19 @@ int GameMaster::negyzet_szama(Index jelenlegi)
     }
 }
 
+bool GameMaster::kesz()
+{
+    bool valasz = true;
+    for (int i=0; i<_megoldas.size(); i++)
+    {
+        if (_megoldas[i] != _save[i])
+        {
+            valasz = false;
+        }
+    }
+    return valasz;
+}
+
 void GameMaster::save(int sorszam, int ertek)
 {
     _save[sorszam]=ertek;
diff --git a/gamemaster.hpp b/gamemaster.hpp
index cf7152b3944bb825b6c808eca5b459148b899691..8efc431c1ed66bf69bb2422ab98d1654ac9bcdec 100644
--- a/gamemaster.hpp
+++ b/gamemaster.hpp
@@ -21,7 +21,8 @@ class GameMaster
         virtual void save(int,int);
 
         std::set<int> aura(int);
-        std::vector<int> szabalytalan(int,std::vector<std::vector<int>>);
+        std::set<int> szabalytalanok();
+        virtual bool kesz();
         virtual int negyzet_szama(Index);
 
     protected:
diff --git a/myapp.cpp b/myapp.cpp
index 017699dbc44c2d1dae4a0c8780a749a633b38cc7..19dabe680ba337af81054aaf660061b79c240674 100644
--- a/myapp.cpp
+++ b/myapp.cpp
@@ -95,56 +95,48 @@ int MyApp::action(std::string id, genv::event ev, int focus)
         if (ev.keycode >= 49 && ev.keycode <= 57)
         {
             palya[focus]->set_ertek(ev.keycode-48);
+            _game->save(focus,palya[focus]->get_ertek());
+
+            set<int> szabalytalan_set = _game->szabalytalanok();
 
-            std::set<int> aura_halmaz = _game->aura(focus);
-            vector<vector<int>> aura_ertekek;
             for (int i=0; i<palya.size(); i++)
             {
-                if (aura_halmaz.find(i) != aura_halmaz.end())
+                if (szabalytalan_set.find(i) != szabalytalan_set.end())
+                {
+                    palya[i]->set_szabalyos(false);
+                }
+                else
                 {
-                    aura_ertekek.push_back({i,palya[i]->get_ertek()});
+                    palya[i]->set_szabalyos(true);
                 }
             }
 
-            vector<int> helytelenek = _game->szabalytalan(palya[focus]->get_ertek(),aura_ertekek);
-
-            if (helytelenek.size() != 0)
+            if (_game->kesz())  /// UJ JATEK
             {
-                palya[focus]->set_szabalyos(false);
-                for (int i=0; i<helytelenek.size(); i++)
-                {
-                    palya[helytelenek[i]]->set_szabalyos(false);
-                }
+                cout << "BEFEJEZTED OMG" << endl;
+                _replay_btn = new Button(this, 30,30,300,80,"uj jatek", [=](){uj_jatek();});
             }
-            _game->save(focus,palya[focus]->get_ertek());
         }
 
         if (ev.keycode==key_delete || ev.keycode==key_backspace)
         {
-            palya[focus]->set_szabalyos(true);
+            palya[focus]->set_ertek(0);
+            _game->save(focus,palya[focus]->get_ertek());
+
+
+            set<int> szabalytalan_set = _game->szabalytalanok();
 
-            /*std::set<int> aura_halmaz = _game->aura(focus);
-            vector<vector<int>> aura_ertekek;
             for (int i=0; i<palya.size(); i++)
             {
-                if (aura_halmaz.find(i) != aura_halmaz.end())
+                if (szabalytalan_set.find(i) != szabalytalan_set.end())
                 {
-                    aura_ertekek.push_back({i,palya[i]->get_ertek()});
+                    palya[i]->set_szabalyos(false);
                 }
-            }
-
-            vector<int> helytelenek = _game->szabalytalan(palya[focus]->get_ertek(),aura_ertekek);
-
-            if (helytelenek.size() != 0)
-            {
-                for (int i=0; i<helytelenek.size(); i++)
+                else
                 {
-                    palya[helytelenek[i]]->set_szabalyos(true);
+                    palya[i]->set_szabalyos(true);
                 }
-            }*/
-
-            palya[focus]->set_ertek(0);
-            _game->save(focus,palya[focus]->get_ertek());
+            }
         }
     }
 
@@ -179,3 +171,8 @@ int MyApp::action(std::string id, genv::event ev, int focus)
     }
     return focus;
 }
+
+void MyApp::uj_jatek()
+{
+    cout << "megnyomtad a replayt" << endl;
+}
diff --git a/myapp.hpp b/myapp.hpp
index d2bf00174bc7929c1b98301228c3747ce82ab92c..c56b8cd33000f17574acf09553883a2e8c8892c5 100644
--- a/myapp.hpp
+++ b/myapp.hpp
@@ -5,15 +5,18 @@
 #include "widget.hpp"
 #include "field.hpp"
 #include "gamemaster.hpp"
+#include "button.hpp"
 
 class MyApp : public Application
 {
     public:
         MyApp(int,int);
         int action(std::string,genv::event,int) override;
+        void uj_jatek();
 
     protected:
         std::vector<Field*> palya;
+        Button* _replay_btn;
 };
 
 #endif // MYAPP_HPP