added PyDoc. Collapsed an if else