Updated to use promises