refactor and test console.logs