implemented code fetching method; fixed bug in node swapping