better error checking.