Use promises for more reliable errors