handling errors at the end