my version
changed to detect inline element.