refactor isElement