remove console.log messages and fix null/undefined minor issue