Refactor. Need to encode data frame.