add ability to write out loop structures