refactor.... And solved problems with buttons