fixed wrong entity length calculation