move more logic from custom element into the class