error handling fixed