minor bug fix and added docstring and namedtuple