added trace
readded swapping of named variables