Added simple error checking.