Add existence check and remove some console.logs