Fixed variable length calculation error