simplified the jquery for easier understanding
minor cleanup.