Fixing error based on console.log