Changed format of function so can be attached to target element. Updated README accordingly