[+] add memory stream
[=] refactoring