Simplified a bit of code and changed a docstring.