Fix Repeated measures ANOVA and code refactor