return errors instead of throwing