return errors instead of panics