add applyRules function
Merge remote-tracking branch 'origin/master'
clean up