Doc string added and simplifications made