Refactor the jquery check