Some refactoring of JS and now leaving search info in text-box