added option to keep elements within defs