correctly nest elements