optimize $ method