some code rafactored; fixed bug with struct types for nodes