commented and working code