Made error check much simpler