logic of trackActivity.java