refactored my code to work with more promises and routing resolution