code structure changes + working topology functions