selected node now is being processed in the script

manages selections inside the script (only tested single selections so
far) added some defensive code