Improves error checking