Add method to calculate encoding