Extended doc strings.
Simplified the code. Added additional doc string to conditions.