added activity algorithm