convert some more code to promises