Cleaning the code with promises chains