Moved $ object declaration to top of file

This helps prevent conflicts with other files/libraries