refactored using Elem prototype