Refactor so jQuery >= 1.9 can be used