Was returning the window instead of re object: js file