Added comments, excluded duplicated function.