Refactor searching petition js