Refactory of ldaEncoder to utility