rename some variables and add logging