Big update to jQuery logic