Use stack instead of broken usage of QByteBuffer
No need for while where if suffices