fixed the bug more genly my adding the missing +1 when allocating the arrays