cleaner code using `elem`