updated analytics function