handling errors better