added optimizations for DOM queries