added docs for $ method and refactored