refactor analyzer to remove duplicated logic