Fix bugs in adding activity functionality