[knot] fix faulty variable scope