trap errors better