Implemented accumulate() and edited comments