added activity algorithm

requested changes done