almost working promises refactor