no need for recursion and a buffer if you know how things are supposed to work