Its not the fastest but it works...
Updated docs
Fixed the error detection.