rearranged jQuery for better organization