Improved jQuery functionality