Added more errors check