Fixed incorrect length of returned segments