use intermediate variable and add more logging