Changed console.log to console.error and removed unnecessary logging