moved console.log below code to only print once