organizing code, additional logging