Added comments and more functionality