Bug fix for nested elements