Fixed getElementFromEmailId function so it works without index attributes