The code shaped according to MVC pattern
Now, nodes selection behaviour is compleate