changes factory to use promises instead of callbacks