refactor and use native angular promises