Refactoring naive bayes application factory