Fixing NRE with logging