Tried to locate the bug
Paid attention to len == -1