Updated previous jQuery 1.9 fix to be more robust