return errors instead of panic()