wrote method to calculate value from variable length bytes