added/moved some shared functionality into universal_template