Improve collections and refactor code for promises