small improvements: removing console.log, simpliffying functions