Adjusted code to new lda interface