added host and error checking