code for processing background activity data