some error checking code