smidge better error checking