Add error checking method