Adding error checking (tmgriffin)