rewrote function ruleParse