code refactoring in regards to
performance, mem usage, easy-to-use API