Lots of error checking work