Replace alert to console.error