refactoring and optimization of Node backend