Added basic error detection.
documented error detection