added isError check