Added comments and rename functions