Move loop from library to node