Added comments
expanded functionality